<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: whats_new.php 140 2013-09-22 07:44:23Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 140 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:44:23 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

if(substr(basename($PHP_SELF), 0,8) != 'advanced') {
	$box_smarty = new Smarty();
	$box_content = '';
	if (MAX_DISPLAY_NEW_PRODUCTS_DAYS != '0') {
		$date_new_products = date("Y.m.d", mktime(1, 1, 1, date(m), date(d) - MAX_DISPLAY_NEW_PRODUCTS_DAYS, date(Y)));
		$days = " AND p.products_date_added > '".$date_new_products."' ";
	}
	$list_data = get_list_data('whats_new');
	$list_data['p_short_desc'] = 1;
	
	if($whats_new = $db->db_query_limit("SELECT
											p.products_id,
                                       		p.products_image,
                                          	p.products_tax_class_id,
                                          	p.products_vpe,
				                          	p.products_vpe_status,
				                          	p.products_vpe_value,
                                          	p.products_price,
                                          	pd.products_name,
                                          	pd.products_description,
                                          	pd.products_short_description
                                       	FROM
                                       		".TABLE_PRODUCTS." p,
                                       		".TABLE_PRODUCTS_DESCRIPTION." pd,
                                       		".TABLE_PRODUCTS_TO_CATEGORIES." p2c,
                                       		".TABLE_CATEGORIES." c
                                       	WHERE
                                       		p.products_status = 1
                                       	AND
                                       		p.products_id = p2c.products_id
                                       	AND
                                       		pd.products_id = p.products_id
                                       	AND
                                       		p.products_id !='".(int)$_GET['products_id']."'
                                       	AND
                                       		c.categories_id = p2c.categories_id
                                      		".$product->groupCheck().$product->fsk18().$days."
                                       	AND
                                       		c.categories_status=1
                                    	GROUP BY
                                    		p.products_id
                                       	ORDER BY
                                       		p.products_date_added DESC".($list_data['box_count'] > 1 ? ", RAND()" :''), $list_data['box_count'])) {
	}

	if($whats_new->_numOfRows) {
		require_once (DIR_FS_INC.'inc.get_products_name.php');
		$rows = 0;
		$whats_new_content = array();
		while(!$whats_new->EOF) { $rows ++;
			$whats_new_content[] = $product->buildDataArray($whats_new->fields, 'thumbnail', $list_data, $rows);
			$whats_new->MoveNext();
		}
		
		$box_smarty->assign('whats_new_content', $whats_new_content);
		$box_smarty->assign('LINK_NEW_PRODUCTS', href_link(FILENAME_PRODUCTS_NEW));
		$box_smarty->assign('language', $_SESSION['language']);
		$box_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
		$box_smarty->assign('html_tpl_path', CURRENT_TEMPLATE.'/html');
		
		 if (!CacheCheck()) {
			$box_smarty->caching = false;
			$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_whatsnew.html');
		} else {
			$box_smarty->caching = true;
			$box_smarty->cache_lifetime = CACHE_LIFETIME;
			$box_smarty->cache_modified_check = CACHE_CHECK;
			$cache_id = $_SESSION['language'].$random_product->fields['products_id'].$_SESSION['customers_status']['customers_status_name'];
			$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_whatsnew.html', $cache_id);
		}
		$smarty->assign('whats_new', $box_content);
	}
}
?>